package com.cloud.user.center.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Ldj
 * @Date 2018/3/1 15:22
 * @Description 用户中心
 */
@RestController
@EnableHystrixDashboard
public class UserController {

    @Value("${server.port}")
    String port;

    @RequestMapping("/hi")
    public String home(@RequestParam String name) {
        return "hi "+name+",i am from port:" +port;
    }

    @Value("${foo}")
    String foo;

    @RequestMapping("/hitest")
    public String test() {
        return "hello " +foo;
    }

    @RequestMapping("/hi2")
    @HystrixCommand(fallbackMethod = "hiError")
    public String test2() {
        return "hello " +foo;
    }

    public String hiError(String name) {
        return "hi,"+name+",sorry,error!";
    }


}
